package com.wilcom.system.service.impl;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wilcom.system.common.BaseResponse;
import com.wilcom.system.common.PageRequest;
import com.wilcom.system.domain.Maintenance;
import com.wilcom.system.domain.Repairrequest;
import com.wilcom.system.mapper.RepairrequestMapper;
import com.wilcom.system.model.request.repairtask.GetRepairRequestsBy;
import com.wilcom.system.service.RepairrequestService;
import org.springframework.stereotype.Service;

/**
* @author lishi
* @description 针对表【repairrequest】的数据库操作Service实现
* @createDate 2024-06-22 02:34:05
*/
@Service
public class RepairrequestServiceImpl extends ServiceImpl<RepairrequestMapper, Repairrequest>
    implements RepairrequestService{

    @Override
    public BaseResponse<Page<Repairrequest>> getAllRepairRequests() {
        QueryWrapper<Repairrequest> queryWrapper = new QueryWrapper<>();
//        List
        return null;
    }

    @Override
    public QueryWrapper<Repairrequest> getQueryWrapper(PageRequest postQueryRequest) {
        QueryWrapper<Repairrequest> queryWrapper = new QueryWrapper<>();
        if (postQueryRequest == null) {
            return queryWrapper;
        }
        return queryWrapper;
    }

    @Override
    public QueryWrapper<Repairrequest> getPendingQueryWrapper(PageRequest postQueryRequest) {
        QueryWrapper<Repairrequest> queryWrapper = new QueryWrapper<>();
        if (postQueryRequest == null) {
            return queryWrapper;
        }
        queryWrapper.eq("status", "pending");
        return queryWrapper;
    }

    @Override
    public QueryWrapper<Repairrequest> GetRepairRequestsBy(GetRepairRequestsBy postQueryRequest) {
        QueryWrapper<Repairrequest> queryWrapper = new QueryWrapper<>();
        if (postQueryRequest == null) {
            return queryWrapper;
        }
        if (StringUtils.isNotBlank(postQueryRequest.getDescription())){
            queryWrapper.like("description", postQueryRequest.getDescription());
        }
        if (StringUtils.isNotBlank(postQueryRequest.getStatus())){
            queryWrapper.eq("status", postQueryRequest.getStatus());
        }
        if (StringUtils.isNotBlank(postQueryRequest.getUrgencyLevel())){
            queryWrapper.eq("urgency_level", postQueryRequest.getUrgencyLevel());
        }
        return queryWrapper;
    }
}




